package com.spzx.channel.service.impl;

import com.spzx.channel.service.IListService;
import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.domain.R;
import com.spzx.common.core.exception.ServiceException;
import com.spzx.common.core.web.page.TableDataInfo;
import com.spzx.product.api.RemoteProductService;
import com.spzx.product.api.domain.SkuQuery;
import org.openxmlformats.schemas.presentationml.x2006.main.impl.CTSlideIdListEntryImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * ClassName: ListServiceImpl
 * Package: com.spzx.channel.service.impl
 * Description:
 *
 * @Author ycy
 * @Create 2024/8/13 11:36
 * @Version 1.0
 */
@Service
public class ListServiceImpl implements IListService {

    @Autowired
    private RemoteProductService remoteProductService;

    @Override
    public TableDataInfo selectProductSkuList(Integer pageNum, Integer pageSize, SkuQuery skuQuery) {
        // 调用远程服务获取商品SKU列表
        R<TableDataInfo> tableDataInfoR= remoteProductService.skuList(pageNum,pageSize,skuQuery, SecurityConstants.INNER);
        // 如果返回码为失败，则抛出异常
        if (R.FAIL == tableDataInfoR.getCode()){
            throw new ServiceException(tableDataInfoR.getMsg());
        }

        // 返回数据
        return tableDataInfoR.getData();
    }
}
